<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>佐心，教家长做父母</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
	<c:set var="ctx" value="${pageContext.request.contextPath}" />
    <link rel="stylesheet" href="assets/css/amazeui.min.css">
    <link rel="stylesheet" href="assets/css/style.css?v=2.3">
    <link rel="stylesheet" href="assets/css/index.css?v=2.3">
    <script>
    	    /** 
     * 返回前一页（或关闭本页面） 
     * <li>如果没有前一页历史，则直接关闭当前页面</li> 
     */  
    function goBack(){  
        if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)){ // IE  
            if(history.length > 0){  
                window.history.go( -1 );  
            }else{  
                location.href="${ctx}/index.jsp";
            }  
        }else{ //非IE浏览器  
            if (navigator.userAgent.indexOf('Firefox') >= 0 ||  
                navigator.userAgent.indexOf('Opera') >= 0 ||  
                navigator.userAgent.indexOf('Safari') >= 0 ||  
                navigator.userAgent.indexOf('Chrome') >= 0 ||  
                navigator.userAgent.indexOf('WebKit') >= 0){  
      
                if(window.history.length > 1){  
                    window.history.go( -1 );  
                }else{  
                    location.href="${ctx}/index.jsp";
                }  
            }else{ //未知的浏览器  
                window.history.go( -1 );  
            }  
        }  
    }  
    </script>
</head>
<body class="bg-gray">
<header data-am-widget="header" class="am-header am-header-default am-header-fixed am-border-bottom">
    <div class="am-header-left am-header-nav">
        <a  onclick="goBack();"  >
            <i class="icon_8"></i>
        </a>
    </div>
    <h1 class="am-header-title">
        我的收藏
    </h1>

    <div class="am-header-right am-header-nav ">
        <a class="am-text-right">
            <span id="btn_edit">编辑</span>
        </a>
    </div>
</header>
<section class="am-padding-bottom-sm" id="amz-main" data-tag="css-nav">

    <div class="am-list-news am-list-news-default collect_list">

        <div class="am-list-news-bd">
            <ul class="am-list">
            </ul>
        </div>
    </div>
</section>
<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">提问删除</div>
        <div class="am-modal-bd">
            你，确定要删除这条记录吗？
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>确定</span>
        </div>
    </div>
</div>

<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script>
	function goPeiDesc(id){
	   location.href="gotoPeixunDesc?studyId="+id;
	}
	function goCounselor(tel){
        location.href="gotoCounselorDescjsp?tel="+tel;
    };
	function goPicNew(id){
        location.href="gotoPicNews2?id="+id;
    };
	$(function(){
    	
    	var shoucanStr=$.ajax({url:"getMyShouChangList",async:false});
        var shoucanJson=JSON.parse(shoucanStr.responseText);
        if(shoucanJson.resultCode=="0"){
			for(var i=0;i<shoucanJson.list.length;i++){
			var html="";
				if(shoucanJson.list[i].type==3){
					var counselorStr=$.ajax({url:"myData2?id="+shoucanJson.list[i].picNewsId,async:false});
					var counselorJson=JSON.parse(counselorStr.responseText);
					html+="<li class='am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left'>";
		            html+="        <div class=' am-u-sm-12 am-list-main box am-padding-left-sm'>";
		            html+="            <div class='width-75px'>";
		            html+="                <a class='' onclick='goCounselor("+counselorJson.counselor.counseTel+")'>";
		            html+="                    <img class='img-65' src='"+counselorJson.counselor.personHead+"'/>";
		            html+="                </a>";
		            html+="            </div>";
		            html+="            <div class='box-1'>";
		            html+="                <h3 class='am-list-item-hd font-color-main'>";
		                                html+=""+counselorJson.counselor.counseName+"<i class='btn-2'><i class='btn-icon-zan'></i>"+counselorJson.counselor.recommenGrade+"</i>";
		            html+="                </h3>";
		            html+="                <div class='font-12  font-color-11'>";
		                                html+=counselorJson.counselor.proName;
		            html+="                </div>";
		            html+="                <div class='font-14  font-color-main'>";
		                                html+="擅长方向： "+counselorJson.counselor.goodDirection;
		            html+="                </div>";
		            html+="            </div>";
		            html+="        </div>";
		            html+="        <div class='height-30 prelative btn-deletes  am-hide am-u-sm-12'>";
		            html+="          <i class='icon_43 am-margin-right-sm' data-id='"+shoucanJson.list[i].id+"'></i>";
		            html+="        </div>";
		            html+="    </li>";
					$(".am-list").append(html);
				}else if(shoucanJson.list[i].type==1){
				
					var sssStr=$.ajax({url:"getAPicNews?id="+shoucanJson.list[i].picNewsId,async:false});
					var sssJson=JSON.parse(sssStr.responseText);
					
					html+="<li  class='am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left'>";
		            html+="        <div onclick='goPicNew("+shoucanJson.list[i].picNewsId+")' class=' am-u-sm-12 am-list-main box am-padding-left-sm'>";
		            html+=sssJson.resultDesc+"</div>";
		            html+="        <div class='height-30 prelative btn-deletes  am-hide am-u-sm-12'>";
		            html+="          <i class='icon_43 am-margin-right-sm' data-id='"+shoucanJson.list[i].id+"'></i>";
		            html+="        </div>";
		            html+="    </li>";
					$(".am-list").append(html);
				}else if(shoucanJson.list[i].type==2){
					var sssStr=$.ajax({url:"getPeinxunDesc?studyId="+shoucanJson.list[i].picNewsId,async:false});
					var jsonCounselor=JSON.parse(sssStr.responseText);
					html+="<li  class='am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left'>";
					html+="<div>";
				    html+="        <div class='box' onclick=goPeiDesc("+jsonCounselor.study.id+")>";
				    html+="            <div><img class='img-70-70' src='"+jsonCounselor.study.studyUrl+"'></div>";
				    html+="            <div class='box-1 am-padding-left-sm'>";
				    html+="                <div class='font-color-13 font-bold font-16 word-space-2' >"+jsonCounselor.study.studyTitle+"</div>";
				    html+="                <div class=''>";
				    html+="                    <ul class='am-pagination am-pagination-default' >";
				    if(null!=jsonCounselor.study.studyLabel && ""!=jsonCounselor.study.studyLabel){
				    	var studyLabel=jsonCounselor.study.studyLabel;
				    	var label=studyLabel.split(",");
				    	for(var j=0;j<label.length;j++){
				    		html+="  <li class='am-active'>";
				   			html+="      <a href='#' class=''>"+label[j]+"</a>";
				    		html+="  </li>";
				    	}
				    }
				    html+="                    </ul>";
				    html+="                </div>";
				    html+="                <div class='font-color-16'>培训方向："+jsonCounselor.study.studyDirection+"</div>";
				    html+="            </div>";
				    html+="        </div>";
				    html+="    </div>";
				     html+="        <div class='height-30 prelative btn-deletes  am-hide am-u-sm-12'>";
		            html+="          <i class='icon_43 am-margin-right-sm' data-id='"+shoucanJson.list[i].id+"'></i>";
		            html+="        </div>";
				    html+="    </li>";
						$(".am-list").append(html);
					}
			}
        }
        
        $('.collect_list').find('.icon_43').on('click', function() {
        $('#my-confirm').modal({
            relatedTarget: this,
            onConfirm: function(options) {
                var $delete = $(this.relatedTarget);
                var id = $delete.data('id');
                var shoucanStr=$.ajax({url:"deleteMyShouChang?id="+id,async:false});
        		var shoucanJson=JSON.parse(shoucanStr.responseText);
        		if(shoucanJson.resultCode=="0"){
        			location.reload(true);
        		}
            },
            onCancel: function() {
            }
        });
    });
        
     });


    $("#btn_edit").on("click",function(){
        if($(this).text()=="编辑"){
            $(".collect_list .btn-deletes").removeClass("am-hide");
            $(this).text("完成");
        } else{
            $(".collect_list .btn-deletes").addClass("am-hide");
            $(this).text("编辑");
        }
    });


</script>
</body>
</html>